#include "CharacterObject.h"

#include <OgreRoot.h>
#include <OgreEntity.h>
#include <OgreViewport.h>
#include <OgreSceneManager.h>

#include "OgreFramework.h"
#include "GameState.h"

CharacterObject::CharacterObject():
    MovableObject()
{
    //ctor
    isWalking=false;
    m_waypoints.clear();

}

CharacterObject::~CharacterObject()
{
    //dtor
}
/** @brief getType
  *
  * @todo: document this function
  */
OBJ_TYPE CharacterObject::getType()
{
    return OBJ_TYP_CHARACTER;
}

/** @brief init
  *
  * @todo: document this function
  */
void CharacterObject::init()
{

    /*
    Ogre::SceneManager *sceneMgr = OgreFramework::getSingletonPtr()->m_pRoot->getSceneManager("GameSceneMgr");

    m_node = sceneMgr->getRootSceneNode()->createChildSceneNode();
    m_entity = sceneMgr->createEntity("character"+Ogre::StringConverter::toString(m_id++), "penguin.mesh");



    m_node->attachObject(m_entity);
    m_node->setInheritOrientation(false);


    setYOffset(0.1);




// Set animation blend mode to additive / cumulative.
    m_entity->getSkeleton()->setBlendMode(Ogre::ANIMBLEND_CUMULATIVE);
    m_entity->setMaterialName("Examples/monsterSkin");

// Get the two halves of the idle animation.
    //  baseAnim = m_entity->getAnimationState("IdleBase");
    //  topAnim = m_entity->getAnimationState("IdleTop");

// Enable both of them and set them to loop.
//   baseAnim->setLoop(true);
    //  topAnim->setLoop(true);
    //  baseAnim->setEnabled(true);
    //  topAnim->setEnabled(true);

    m_node->setScale(Ogre::Vector3(0.01,0.01,0.01));



    m_entity->setQueryFlags(QUERY_CHARACTER);

   // m_animCreature->setPosition(Ogre::Vector3(m_position.x,m_Yoffset,m_position.y));
       m_node->setPosition(Ogre::Vector3(m_position.x,m_Yoffset,m_position.y));

       */

}

/** @brief update
  *
  * @todo: document this function
  */
void CharacterObject::update(double timeSinceLastFrame)
{
// Figure out the direction and distance we need to walk until the target

/*


    Ogre::Vector2 direction;
    float distance;
    if (m_waypoints.size()>0)
    {
        isWalking = true;
        walkTo((*m_waypoints.begin()));
        m_animCreature->update( timeSinceLastFrame);



    }
    else
    {
        isWalking = false;

    }

Object::update(timeSinceLastFrame);
*/
}

/** @brief clear
  *
  * @todo: document this function
  */
void CharacterObject::clear()
{

}


